
const first = new Promise((resolve,reject)=>{
    setTimeout(resolve, 1000, '兑现(first)');
});
first.then( result => console.log( 'first then: ', result ) );

const second = new Promise((resolve,reject)=>{
    setTimeout(resolve, 0, '兑现(second)');
});
second.then( result => console.log( 'second then: ', result ) );

const third = new Promise((resolve,reject)=>{
    setTimeout(reject, 100, '拒绝(third)');
});
third.catch( result => console.log( 'third catch: ', result ) );

const promises = [ first, second, third ];

const last = Promise.race( promises );
last.then( results => console.log( results ) )
    .catch( reason => console.log( reason ) );

// 总结:
// Promise.race( iterable )
// 一旦参数iterable中有一个Promise实例被兑现或被拒绝,
// 则race返回的Promise实例就被兑现或被拒绝